<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">


<ui:composition template="/templates/templateDiretor.xhtml">
	<ui:define name="conteudo">
		<h:form>
			<p:dataTable rows="10" paginator="true" emptyMessage="Não há turma cadastrada" value="#{mBAula.aulaes}" var="aula">
				<p:column headerText="Horário">
					<h:outputText value="#{aula.horario}" />
				</p:column>
				<p:column headerText="Professor">
					<p:commandLink value="#{aula.professor.usuario.nome}" action="#{mBProfessor.setarProfessorDialog}" oncomplete="professorDialog.show()" update="@form"> 
						<f:setPropertyActionListener target="#{mBProfessor.professorVizualizacao}" value="#{aula.professor}"/>
					</p:commandLink>
				</p:column>
				<p:column headerText="Sala">
					<h:outputText value="#{aula.sala.nome}" />
				</p:column>
				<p:column headerText="Disciplina">
					<p:commandLink value="#{aula.disciplina.nome}" oncomplete="disciplinaDialog.show()" update="@form">
						<f:setPropertyActionListener target="#{mBDisciplina.disciplinaVisualizacao}" value="#{aula.disciplina}"></f:setPropertyActionListener>
					</p:commandLink>
				</p:column>
				<p:column headerText="Turma">
					<p:commandLink value="#{aula.turma.nome}" oncomplete="turmaDialog.show()" action="#{mBTurma.setarTurmaDialog}" update="@form">
						<f:setPropertyActionListener target="#{mBTurma.turmaVisualizacao}" value="#{aula.turma}"/>
					</p:commandLink>
				</p:column>
			</p:dataTable>
			<p:dialog widgetVar="turmaDialog" header="Turma">
				<ui:include src="../../comum/turma.xhtml">
					<ui:param name="turma" value="#{mBTurma.turmaVisualizacao}"/>
				</ui:include>
			</p:dialog>
			<p:dialog widgetVar="disciplinaDialog" header="Disciplina">
				<ui:include src="../../comum/disciplina.xhtml">
					<ui:param name="disciplina" value="#{mBDisciplina.disciplinaVisualizacao}"/>
				</ui:include>
			</p:dialog>
			<p:dialog widgetVar="professorDialog" height="500" header="Professor">
				<ui:include src="../../comum/professor.xhtml">
					<ui:param name="professor" value="#{mBProfessor.professorVizualizacao}"/>
				</ui:include>
			</p:dialog>
		</h:form>

		<h:form>
			<p:panel header="Aula">
				<h:panelGrid columns="3">
					<h:outputLabel value="Horario:" />
					<p:inputText value="#{mBAula.aula.horario}" required="true" requiredMessage="Escolha um horário"/>
					<h:outputLabel value="" />
					<h:outputLabel value="Disciplina:" />
					<h:outputText style="font-weight: bold;"
						value="#{mBAula.aula.disciplina.nome}" />
					<p:commandButton value="Escolher Disciplina"
						oncomplete="discDlg.show();" />

					<h:outputLabel value="Sala:" />
					<h:outputText style="font-weight: bold;"
						value="#{mBAula.aula.sala.nome}" />
					<p:commandButton value="Escolher Sala" oncomplete="salaDlg.show();" />

					<h:outputLabel value="Professor:" />
					<h:outputText style="font-weight: bold;"
						value="#{mBAula.aula.professor.usuario.nome}" />
					<p:commandButton value="Escolher Professor"
						oncomplete="profDlg.show();" />
					
					<h:outputLabel value="Turma:" />
					<h:outputText style="font-weight: bold;"
						value="#{mBAula.aula.turma.nome}" />
					<p:commandButton value="Escolher Turma"
						oncomplete="turmaDlg.show();" />
						
					<p:commandButton value="Cadastrar" action="#{mBAula.cadastrar}" ajax="false"/>
				</h:panelGrid>
			</p:panel>
			
			<p:dialog modal="true" closable="true" widgetVar="turmaDlg" id="turmaDialog">
				<p:dataTable var="Turma" id="listarTurma" value="#{mBTurma.turmas}"
				emptyMessage="Não há Turmaes cadastrados" rows="10" rendered="#{!mBTurma.vizualizavel}" paginator="true">
				<p:column filterBy="#{Turma.serie}" filterMatchMode="contains">
					<f:facet name="header">
						Serie
					</f:facet>
					<h:outputText value="#{Turma.serie}" />
				</p:column>
				<p:column filterBy="#{Turma.nome}" filterMatchMode="contains">
					<f:facet name="header">
						Nome
					</f:facet>
					<h:outputText value="#{Turma.nome}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						Escolha
					</f:facet>
					<p:commandButton value="Escolher" ajax="false" action="#{mBAula.verificarTurma}">
						<f:setPropertyActionListener target="#{mBAula.aula.turma}"
							value="#{Turma}" />
					</p:commandButton>

				</p:column>
			</p:dataTable>
			</p:dialog>
			
			<p:dialog modal="true" closable="true" widgetVar="salaDlg"
				id="salaDialog">
				<p:dataTable var="sala" id="listarsala" value="#{mBSala.salas}"
					emptyMessage="Não há salas cadastrados" rows="10"
					rendered="#{!mBSala.visualizar}" paginator="true">
					<p:column filterBy="#{sala.nome}" filterMatchMode="contains"
						headerText="Nome">
						<h:outputText value="#{sala.nome}" />
					</p:column>
					<p:column filterBy="#{sala.escola.nome}" filterMatchMode="contains"
						headerText="Nome">
						<h:outputText value="#{sala.escola.nome}" />
					</p:column>
					<p:column>
						<f:facet name="header">
						Escolha
					</f:facet>
						<p:commandButton value="Escolher" ajax="false" action="#{mBAula.verificarSala}">
							<f:setPropertyActionListener target="#{mBAula.aula.sala}"
								value="#{sala}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</p:dialog>

			<p:dialog modal="true" closable="true" widgetVar="discDlg"
				id="discDialog">
				<p:dataTable value="#{mBDisciplina.listaDisc}" var="disciplina"
					emptyMessage="Nenhuma disciplina cadastrada" rows="10"
					paginator="true">
					<p:column headerText="Nome" filterBy="#{disciplina.nome}"
						filterMatchMode="contains">
						<h:outputText value="#{disciplina.nome}" />
					</p:column>
					<p:column headerText="Sigla" filterBy="#{disciplina.sigla}"
						filterMatchMode="contains">
						<h:outputText value="#{disciplina.sigla}" />
					</p:column>
					<p:column headerText="Escolha">
						<p:commandButton value="Escolher" update="@form">
							<f:setPropertyActionListener target="#{mBAula.aula.disciplina}"
								value="#{disciplina}" />
						</p:commandButton>

					</p:column>
				</p:dataTable>

			</p:dialog>

			<p:dialog modal="true" closable="true" widgetVar="profDlg"
				id="profDialog">
				<p:dataTable var="professor" id="listarprofessor"
					value="#{mBProfessor.professores}"
					emptyMessage="Não há professors cadastrados" rows="10">
					<p:column filterBy="#{professor.usuario.matricula}"
						filterMatchMode="contains">
						<f:facet name="header">
						Matricula
					</f:facet>
						<h:outputText value="#{professor.usuario.matricula}" />
					</p:column>
					<p:column filterBy="#{professor.usuario.nome}"
						filterMatchMode="contains">
						<f:facet name="header">
						Nome
					</f:facet>
						<h:outputText value="#{professor.usuario.nome}" />
					</p:column>
					<p:column filterBy="#{professor.email}" filterMatchMode="contains">
						<f:facet name="header">
						Email
					</f:facet>
						<h:outputText value="#{professor.email}" />
					</p:column>
					<p:column headerText="Escolha">
						<p:commandButton action="#{mBAula.verificarProfessor}" value="Escolher" ajax="false">
							<f:setPropertyActionListener target="#{mBAula.aula.professor}"
								value="#{professor}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</p:dialog>
		
			
		</h:form>
	</ui:define>
</ui:composition>
</html>